package com.pro.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Objects;

/**
 * @Author 谭金诚
 * @Description TODO
 * @Date 2022/1/22 9:43
 * @Version 1.0
 */
public class LoginRecord {

    private Integer id;
    private Integer userId;//用户id
    private String loginIp;//登录IP
    private String loginAddress;//登录地区
    private Integer loginState;//登录状态，2登录成功，3登陆失败
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private String loginDate;//登陆时间
    private Integer loginType;//类型，2后台，3前台

    public LoginRecord() {
    }

    public LoginRecord(Integer id, Integer userId, String loginIp, String loginAddress, Integer loginState, String loginDate, Integer loginType) {
        this.id = id;
        this.userId = userId;
        this.loginIp = loginIp;
        this.loginAddress = loginAddress;
        this.loginState = loginState;
        this.loginDate = loginDate;
        this.loginType = loginType;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public String getLoginAddress() {
        return loginAddress;
    }

    public void setLoginAddress(String loginAddress) {
        this.loginAddress = loginAddress;
    }

    public Integer getLoginState() {
        return loginState;
    }

    public void setLoginState(Integer loginState) {
        this.loginState = loginState;
    }

    public String getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(String loginDate) {
        this.loginDate = loginDate;
    }

    public Integer getLoginType() {
        return loginType;
    }

    public void setLoginType(Integer loginType) {
        this.loginType = loginType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LoginRecord that = (LoginRecord) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(userId, that.userId) &&
                Objects.equals(loginIp, that.loginIp) &&
                Objects.equals(loginAddress, that.loginAddress) &&
                Objects.equals(loginState, that.loginState) &&
                Objects.equals(loginDate, that.loginDate) &&
                Objects.equals(loginType, that.loginType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, userId, loginIp, loginAddress, loginState, loginDate, loginType);
    }

    @Override
    public String toString() {
        return "LoginRecord{" +
                "id=" + id +
                ", userId=" + userId +
                ", loginIp='" + loginIp + '\'' +
                ", loginAddress='" + loginAddress + '\'' +
                ", loginState=" + loginState +
                ", loginDate='" + loginDate + '\'' +
                ", loginType=" + loginType +
                '}';
    }
}
